/***************************************************************************
创建者：华磊
 开始时间：               : 2020.1１.09
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   左侧自定义功能视窗对话框
*                                                                         *
 ***************************************************************************/
#include "leftfun.h"
#include "ui_leftfun.h"
//#include <QDebug>

LeftFun::LeftFun(int styleId,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LeftFun)
{
    ui->setupUi(this);

    setGeometry(rect().x(), rect().y()+480,70, 335);
    initialDisplayStyle(styleId);
    //ui->pushButton_3->setEnabled(false);
    //ui->pushButton_4->setEnabled(false);
}

LeftFun::~LeftFun()
{
    delete ui;
}
void LeftFun::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->pushButton_left2->setGeometry(10,70,51,47);
        ui->pushButton_left3->setGeometry(10,130,51,47);
        //ui->pushButton_left4->setGeometry(10,190,51,47);
        break;
    default:
        break;
    }
}
int LeftFun::setButtonF1View(QString text, QString imagePath)
{
    ui->pushButton_left1->setText(text);
    ui->pushButton_left1->setStyleSheet( QString("image: url(%1);border-width:0px;border-style:outset;").arg(imagePath));
    update();
}

int LeftFun::setButtonF2View(QString text, QString imagePath)
{
    ui->pushButton_left2->setText(text);
    ui->pushButton_left2->setStyleSheet( QString("image: url(%1);border-width:0px;border-style:outset;").arg(imagePath));
    update();
}

int LeftFun::setButtonF3View(QString text, QString imagePath)
{
    ui->pushButton_left3->setText(text);
    ui->pushButton_left3->setStyleSheet( QString("image: url(%1);border-width:0px;border-style:outset;").arg(imagePath));
    update();
}

int LeftFun::setButtonF4View(QString text, QString imagePath)
{
    ui->pushButton_left4->setText(text);
    ui->pushButton_left4->setStyleSheet( QString("image: url(%1);border-width:0px;border-style:outset;").arg(imagePath));
    update();
}


void LeftFun::on_pushButton_left2_clicked()
{
    emit leftFunEmpty2_signal();
}

void LeftFun::on_pushButton_left3_clicked()
{
    emit leftFunEmpty3_signal();
}

void LeftFun::on_pushButton_left4_clicked()
{
    emit leftFunEmpty4_signal();
}

//void LeftFun::updateView()
//{
//    //qDebug()<<"update";
//    ui->pushButton->setText(button1Text);
//    ui->pushButton->setStyleSheet(QString("border-image: url(%1);").arg(button1PictureAddress));
//    ui->pushButton_2->setText(button2Text);
//    ui->pushButton_2->setStyleSheet(QString("border-image: url(%1);").arg(button2PictureAddress));
//    ui->pushButton_3->setText(button3Text);
//    ui->pushButton_3->setStyleSheet(QString("border-image: url(%1);").arg(button3PictureAddress));
//    ui->pushButton_4->setText(button4Text);
//    ui->pushButton_4->setStyleSheet(QString("border-image: url(%1);").arg(button4PictureAddress));
//}

void LeftFun::changeLanguageSlot(int language)
{
    if(1 == language)
    {
        translator.load("/agvwork/AgvHmi/baseBag/hmiProject/language/leftFunEnglishLan.qm");
        qApp->installTranslator(&translator);
    }
    else
    {
        qApp->removeTranslator(&translator);
    }

    ui->retranslateUi(this);
}

void LeftFun::on_pushButton_left1_clicked()
{
    emit leftFunEmpty1_signal();
}
